﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.BLL;

public partial class _Default : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (IsPostBack) return;
		using (var pm = new PluginsManager())
		{
			lvDesktop.DataSource = pm.GetPlugins(Session["userManage"] as PBOffice.DAL.User);
			lvDesktop.DataBind();
		}
	}

	protected void bResetDesktop_Click(object sender, EventArgs e)
	{
		using (var pm = new PluginsManager())
		{
			pm.ResetDesktop(Session["userManage"] as PBOffice.DAL.User);
			lvDesktop.DataSource = pm.GetPlugins(Session["userManage"] as PBOffice.DAL.User);
			lvDesktop.DataBind();
		}
	}
	protected void lvDesktop_ItemDataBound(object sender, ListViewItemEventArgs e)
	{
		var plugin = e.Item.DataItem as PBOffice.DAL.Plugin;
		var physicalPath = Server.MapPath(plugin.P_Path);
		if (System.IO.File.Exists(physicalPath))//存在控件，加载它
		{
			e.Item.FindControl("pContent").Controls.Add(LoadControl(plugin.P_Path));
		}
	}
}